<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class TestRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        // 获取路由URI参数
        $commentId = $this->route('comment');
        return Comment::where('id', $commentId)
                      ->where('user_id', Auth::id())->exists();
        // return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
        ];
    }

    // OPTIONAL OVERRIDE
    // public function forbiddenResponse()
    // {
    //     // Optionally, send a custom response on authorize failure 
    //     // (default is to just redirect to initial page with errors)
    //     // 
    //     // Can return a response, a view, a redirect, or whatever else
    //     return new Response('Forbidden', 403);
    // }

    // OPTIONAL OVERRIDE
    // public function response()
    // {
    //     // If you want to customize what happens on a failed validation,
    //     // override this method.
    //     // See what it does natively here: 
    //     // Illuminate/Foundation/Http/FormRequest.php
    // }
}
